﻿using System.Windows;
using System.Windows.Controls;
using Flux.Editor.Models;

namespace Flux.Editor.Panes
{
	public class PaneTemplateSelector
		: DataTemplateSelector
	{
		public DataTemplate StartPageViewTemplate { get; set; }
		public DataTemplate MapPaneViewTemplate { get; set; }
		
		public override DataTemplate SelectTemplate(object item, DependencyObject container)
		{
			if (item is StartPageModel) return StartPageViewTemplate;
			if (item is MapPaneModel)
			{
				((ContentPresenter) container).DataContext = ((MapPaneModel) item).Map;
				return MapPaneViewTemplate;
			}

			return base.SelectTemplate(item, container);
		}
	}
}